import java.util.Scanner;

public class hw4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入求斐波那切数列第几项：");
        int n = scanner.nextInt();
        System.out.println("斐波那切数列第" + n + "项为" + fib(n));
    }

    public static int fib(int n) {
        if (n == 1 || n == 2) {
            return 1;
        } else {
            int f1 = 1, f2 = 1;
            int f3 = 0;
            int i = n - 2;//循环次数
            while (i != 0) {
                f3 = f1 + f2;
                f1 = f2;
                f2 = f3;
                i--;

            }
            return f3;
        }

    }
}


